# -*- coding: utf-8 -*-
from classes import *
from time import clock
import gui
__author__="Kamil"
__date__ ="$2010-03-02 20:09:30$"


def svq(shapes,times,eta,beta,cbvectors,update):
    eta0 = eta
    for s in range(len(shapes)):    #for each image
        start = clock()
        for i in range(times):  # iterations of algorithm
            point = shapes[s].pickRandomPoint()
            f = cbvectors[s].calcF(point, beta)
            cbvectors[s].move(point, f, eta)
            eta = eta0 * (times - i)/times
            #if update == 'iteration':
            #    yield s
        #if update == 'shape':
        yield s
        print clock() - start
        
    #return cbvectors
